package cn.mvc.web.common;

import demo.common.entity.CommonEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpStatus;

import java.util.List;

/**
 * 统一的返回结果，根据公司内部的实际规范来定义
 *
 * @author yexi
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Builder
public class Result<T> {

    @Builder.Default
    private int status = HttpStatus.OK.value();
    private T data;
    @Builder.Default
    private String message = "成功";

    public static void main(String[] args) {
        Result.ResultBuilder<List<CommonEntity>> resultBuilder = Result.builder();
        Result<List<CommonEntity>> result = resultBuilder
                .status(HttpStatus.OK.value())
                .build();
        System.out.println(result);
    }

}